﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
using System.IO;
using JumbotCms.Common;
namespace JumbotCms.Install
{
    public partial class _step2 : JumbotCms.Common.BasicPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (System.Web.HttpContext.Current.Application["CMS:BasePath"] == null)
                Response.Redirect("index.aspx");
            else
                if (!Page.IsPostBack)
                {
                    string[] setting;
                    doh.Reset();
                    string tempStr = doh.GetValue("jcms_normal_system", "Info").ToString();
                    if (tempStr.Length > 0)
                    {
                        setting = tempStr.Split('§');

                        if (setting.Length < 18)
                        {
                            tempStr = tempStr + "§§§§§§§§§§§§§§§§§§";
                            setting = tempStr.Split('§');
                        }

                        try
                        {
                            this.txtTitle.Text = setting[0].ToString();
                            this.rblOpen.Items.FindByValue(setting[1].ToString()).Selected = true;
                            this.txtMessage.Text = setting[2].ToString();
                            this.rblClose.Items.FindByValue(setting[3].ToString()).Selected = true;
                            this.txtOpenTime.Text = setting[4].ToString();
                            this.rblReg.Items.FindByValue(setting[5].ToString()).Selected = true;
                            //this.rblEmail.Items.FindByValue(setting[6].ToString()).Selected = true;
                            this.rblEmail.Items.FindByValue("1").Selected = true;
                            this.rblAdmin.Items.FindByValue(setting[7].ToString()).Selected = true;
                            this.txtPageCount.Text = setting[8].ToString();
                            this.txtUrl.Text = ServerUrl();
                            this.txtKeys.Text = setting[10].ToString();
                            this.txtDescription.Text = setting[11].ToString();
                            this.rblSkin.Items.FindByValue(setting[12].ToString()).Selected = true;
                            this.txtDir.Text = Jumbot.Common.DirFile.AppPath();
                            this.rbStaticExt.Items.FindByValue(setting[14].ToString()).Selected = true;
                            this.txtICP.Text = setting[15].ToString();
                        }
                        catch (Exception) { }
                    }
                }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string url = this.txtUrl.Text;
            string setting = "";
            setting = Jumbot.Common.Strings.SafetyStr(this.txtTitle.Text).Replace('§', ',') + "§" +
                this.rblOpen.SelectedItem.Value + "§" +
                Jumbot.Common.Strings.SafetyStr(this.txtMessage.Text).Replace('§', ',') + "§" +
                this.rblClose.SelectedItem.Value + "§" +
                this.txtOpenTime.Text + "§" +
                this.rblReg.SelectedItem.Value + "§" +
                this.rblEmail.SelectedItem.Value + "§" +
                this.rblAdmin.SelectedItem.Value + "§" +
                this.txtPageCount.Text + "§" +
                url + "§" +
                Jumbot.Common.Strings.SafetyStr(this.txtKeys.Text).Replace('§', ',') + "§" +
                Jumbot.Common.Strings.SafetyStr(this.txtDescription.Text).Replace('§', ',') + "§" +
                this.rblSkin.SelectedItem.Value + "§" +
                this.txtDir.Text + "§" +
                this.rbStaticExt.SelectedItem.Value + "§" +
                this.txtICP.Text.Replace('§', ',');
            doh.Reset();
            doh.AddFieldItem("info", setting);
            doh.Update("jcms_normal_system");
            Response.Redirect("step3.aspx");
        }
    }
}
